
string(ASCII 27 __C_Esc)
set(__C_ColorReset  "${__C_Esc}[m")
set(__C_ColorBold   "${__C_Esc}[1m")
set(__C_Red         "${__C_Esc}[31m")
set(__C_Green       "${__C_Esc}[32m")
set(__C_Yellow      "${__C_Esc}[33m")
set(__C_Blue        "${__C_Esc}[34m")
set(__C_Magenta     "${__C_Esc}[35m")
set(__C_Cyan        "${__C_Esc}[36m")
set(__C_White       "${__C_Esc}[37m")
set(__C_BoldRed     "${__C_Esc}[1;31m")
set(__C_BoldGreen   "${__C_Esc}[1;32m")
set(__C_BoldYellow  "${__C_Esc}[1;33m")
set(__C_BoldBlue    "${__C_Esc}[1;34m")
set(__C_BoldMagenta "${__C_Esc}[1;35m")
set(__C_BoldCyan    "${__C_Esc}[1;36m")
set(__C_BoldWhite   "${__C_Esc}[1;37m")
set(CMsgReset       "${__C_ColorReset}")
set(CMsgError       "${__C_BoldRed}")
set(CMsgWarn        "${__C_BoldYellow}")
set(CMsgInfo        "${__C_Green}")

# Color message
# cmsg(ERROR|WARN|INFO|message mode, Text)
function(cmsg)
    list(GET ARGV 0 Mode)
    if(Mode STREQUAL ERROR)
        set(Mode FATAL_ERROR)
    elseif(Mode STREQUAL INFO)
        set(Mode STATUS)
    elseif(Mode STREQUAL WARN)
        set(Mode WARNING)
    endif()

    if((Mode STREQUAL FATAL_ERROR) OR (Mode STREQUAL SEND_ERROR))
        list(REMOVE_AT ARGV 0)
        message(${Mode} "${CMsgError}${ARGV}${CMsgReset}")
    elseif(Mode STREQUAL WARNING)
        list(REMOVE_AT ARGV 0)
        message(${Mode} "${CMsgWarn}${ARGV}${CMsgReset}")
    elseif(Mode STREQUAL STATUS)
        list(REMOVE_AT ARGV 0)
        message(${Mode} "${CMsgInfo}${ARGV}${CMsgReset}")
    else()
        message("${ARGV}")
    endif()
endfunction()
